﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using Enter.Common;

namespace Enter.Web.SystemAdmin.GoodClass
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string str = this.TextBox1.Text;//.Replace("\r\n", "").Replace("\t", "");
            str = str.Replace("</option>", "、");
          //MatchCollection ms=  Regex.Matches(this.TextBox1.Text,"/(?<=<option[^>]*>).*(?=<\\/option>)/ ");
          //  foreach(Match m in ms)
          //  {
           
          //  }
            this.TextBox2.Text = Regex.Replace(str, "\\<option\\s+.*\\>", "").Replace("\r\n", "").Replace("\t", "").TrimEnd('、');
         //   this.TextBox1.Text = "";
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            string[] files = FileHelper.File_List("G:\\项目\\网上商城\\数据\\");
          int code = 1;
          foreach (string file in files)
          {
              string content = FileHelper.readFile(file, "GB2312").Replace("不能发布或编辑此类宝贝，所属的宝贝模板已被屏蔽","");
              content = content.Replace("</span></li>", "；").Replace("</option>", "、").Replace("</label></li>", "|");//.Replace("</label>$</li>", "；");
              string thle = RegexHelper.NoHTML(content).Replace("&#183;", "·").Replace("&amp;", "&").Replace("&#39;", "'").Replace(":", ":\r\n");
              int s1=thle.IndexOf("：")+1;
              int e1=thle.IndexOf("；");
              string br = thle.Substring(s1, e1 - s1).Trim('、');
              string p = thle.Substring(e1 + 1, thle.Length - e1-1);
              FileHelper.OverWriteGB2312File(file.Replace("数据", "属性"), p);
              FileHelper.OverWriteGB2312File(file.Replace("数据", "品牌"), br);
          }
          
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            string str = this.TextBox1.Text.Replace("\r\n", "").Replace("+", "");
            this.TextBox2.Text = Regex.Replace(str, "\\(\\d+\\)", ",");
            this.TextBox1.Text = "";
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            string str = this.TextBox1.Text.Replace("\r\n", "");
            this.TextBox2.Text = Regex.Replace(str, "\\(\\d+\\)", "、").TrimEnd('、') + "*";
            this.TextBox1.Text = "";
        }
        protected void Button6_Click(object sender, EventArgs e)
        {
            string str = this.TextBox1.Text.Replace("}", "}\r\n");
            this.TextBox2.Text = str;
           
        }
    }
}